function init() {
	var request = opensocial.newDataRequest();
	request.add(request.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER),"viewer");
	request.send();
}

function persistViewer(response) {
	var viewer = response.get("viewer");
	if (viewer.hadError()) {
		alert("Has erros on application request for viewer!");
		return;
	}
	if (opensocial.DataRequest.PersonId.OWNER != viewer.getId()) {
		var params = {};
		params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.JSON;
		params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
		params["viewer.id"] = viewer.getId();
		params["viewer.name"] = viewer.getDisplayName();
		params["owner.id"] = opensocial.DataRequest.PersonId.OWNER;
		gadgets.io.makeRequest("http://www.magicnumber.com.br/visitcounter/persistdata", 
			displayMessage,
			params);
	} else {
		alert("you is your self!");
	}
}

function displayMessage(response) {
	var data = response.data;
	document.getElementById("content_div").innerHTML = data.getMessage();
}

init();